import axios from 'axios'

const service = axios.create({
  baseURL: 'http://101.42.22.211:8010/front/api'
})

// 添加请求拦截器，在请求头中加token
service.interceptors.request.use(
  config => {
    if (localStorage.getItem('token')) {
      config.headers.Authorization = 'Bearer ' + localStorage.getItem('token')
    }

    return config
  },
  error => {
    return Promise.reject(error)
  }
)

export default service
